package com.st.Controller;

import com.st.Service.IOrderService;
import com.st.entity.Order;
import com.st.entity.OrderItem;
import com.st.entity.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/order1")
public class OrderController {

    @Autowired
    private IOrderService iOrderService;
    //添加订单
    @RequestMapping("/addOrder")
    public Result addOrder(@RequestBody OrderItem order){
        return iOrderService.addOrder(order);
    }
    //删除订单
    @RequestMapping("/delOrder")
    public Result delOrder(String id){
        return iOrderService.delOrder(id);
    }
    //查询订单
    @RequestMapping("/searchOrder")
    public List<Order> searchOrder(Integer userId){
        return iOrderService.findOrderById(userId);
    }
}
